<?php

namespace app\index\controller\my;

use app\index\model\UM as UM;
use app\index\service\AccountBillService;
use ShidianUtil\Thinkphp\Response\ApiResponse;
use think\APP;
use think\Request as Request;

/**
 * AccountBill 控制器
 * Class AccountBill
 * @package app\index\controller\my;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 * @see \app\index\validate\my\AccountBill
 */
class AccountBill
{
    // 请求参数
    private Request $request;

    // service
    private AccountBillService $service;

    public function __construct(Request $request, AccountBillService $accountBillService)
    {
        $this->request = $request;
        $this->service = $accountBillService;
    }

    /**
     * 账单-列表
     * @param UM|null $user
     * @return ApiResponse
     * @url /my/account_bill/index
     */
    public function index(UM $user): ApiResponse
    {
        $request = $this->request;

        $isIncome = $request->param('isIncome', 0);
        $page = $request->param('page', 1);
        $page_size = $request->param('page_size', 20);

        return ApiResponse::success($this->service->index($user, $isIncome, $page, $page_size));
    }

}
